package com.ruoyi.teacher.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.teacher.domain.StuZxjInfo;
import com.ruoyi.teacher.mapper.StuZxjInfoMapper;
import com.ruoyi.teacher.service.IStuZxjInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StuZxjInfoImpl implements IStuZxjInfoService {
    @Autowired
    private StuZxjInfoMapper stuZxjInfoMapper;

    /**
     * 更新审批记录
     */
    @Override
    public int updateStuZxjInfo(StuZxjInfo stuZxjInfo) {
        stuZxjInfoMapper.updateStatus(stuZxjInfo);
        return stuZxjInfoMapper.updateStuZxjInfo(stuZxjInfo);
    }

    /**
     * 根据助学金序号查审批记录
     */
    @Override
    public StuZxjInfo getByZxjId(Long zxjId) {
        return stuZxjInfoMapper.getByZxjId(zxjId);
    }

    /**
     * 添加一条审批记录
     */
    @Override
    public int saveStuZxjInfo(StuZxjInfo stuZxjInfo) {
        stuZxjInfoMapper.updateStatus(stuZxjInfo);
        stuZxjInfo.setUpdateTime(DateUtils.getNowDate());
        return stuZxjInfoMapper.saveStuZxjInfo(stuZxjInfo);
    }

    /**
     * 根据教师id获取该教师需要审批的记录合集
     */
    @Override
    public List<StuZxjInfo> getByUserId(Long userId) {
        return stuZxjInfoMapper.getByUserID(userId);
    }

    /**
     * 批量删除审批记录
     */
    @Override
    public int deleteByZxjIds(Long[] zxjIds) {
        return stuZxjInfoMapper.deleteByZxjIds(zxjIds);
    }

    @Override
    public List<StuZxjInfo> getStuZxjInfoList(StuZxjInfo stuZxjInfo) {
        return stuZxjInfoMapper.getStuZxjInfoList(stuZxjInfo);
    }

    @Override
    public boolean nengshengpi(Long zxjId, Long userId) {
        return stuZxjInfoMapper.isNengshengpi(zxjId, userId);
    }

    @Override
    public boolean isNewShengpi(Long zxjId) {
        return stuZxjInfoMapper.isNewShengpi(zxjId);
    }
}
